package com.aivin.web;

import com.aivin.entity.TbPic;
import com.aivin.entity.TbUser;
import com.aivin.service.PicService;
import com.aivin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 *  restful设计
 */
@Controller//@Service @Component
@RequestMapping("/user")// url:/模块/资源/{id}/细分 /seckill/list
public class UserController {

    @Autowired
    private UserService  mysSrvice  ;

    //http://192.168.0.119:8081/findYou/getAllUserByLimit/0/100

    @RequestMapping(value = "/getAllUserByLimit/{offset}/{limit}",  method = RequestMethod.GET   )
    public String   getAllUserByLimit(@PathVariable int offset , @PathVariable int limit , Model model ) {
        List<TbUser> userlist =null ;

        userlist = mysSrvice.queryAllUserFy(offset ,limit) ;
        model.addAttribute("userlist", userlist);
        return "userlist";
    }

//
//    @RequestMapping(value = "/{seckillId}/detail", method = RequestMethod.GET)
//    public String detail(@PathVariable("seckillId") int seckillId, Model model) {
//        if (seckillId == null) {
//            return "redirect:/seckill/list";
//        }
//        Seckill seckill = seckillService.getById(seckillId);
//        if (seckill == null) {
//            return "forward:/seckill/list";
//        }
//        model.addAttribute("seckill", seckill);
//        return "detail";
//    }

}
